package com.hua.jdk8;

import java.util.Arrays;
import java.util.List;

/**
 * @author: _hua
 * @created: 2019/3/30.
 * @updater:
 * @description:
 */

/**
 * 方法引用是使用两个冒号::这个操作符号。
 * 使用Lambda表达式遍历List集合
 */
public class LmadaList {
    public static void main(String args[]){

        //Prior Java 8 :
        List features1 = Arrays.asList("Lambdas", "Default Method",
                "Stream API", "Date and Time API");
        for (Object feature1 : features1) {
            System.out.println(feature1);
        }

        //In Java 8:
        List features = Arrays.asList("Lambdas", "Default Method", "Stream API",
                "Date and Time API");
        features.forEach(n -> System.out.println(n));

        // Even better use Method reference feature of Java 8
        // method reference is denoted by :: (double colon) operator
        // looks similar to score resolution operator of C++
        features.forEach(System.out::println);
    }
}
